package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocModule;
import org.ycx.doc.dao.model.DocModuleExample;

public interface DocModuleMapper {
    @SelectProvider(type=DocModuleSqlProvider.class, method="countByExample")
    long countByExample(DocModuleExample example);

    @DeleteProvider(type=DocModuleSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocModuleExample example);

    @Delete({
        "delete from doc_module",
        "where MODULE_ID = #{moduleId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer moduleId);

    @Insert({
        "insert into doc_module (APP_ID,MODULE_NAME, ",
        "MODULE_TYPE, PID, ",
        "MODULE_CODE, M_VERSION, ",
        "CREATE_TS, CREATE_UID, ",
        "UPDATE_TS, UPDATE_UID, ",
        "STATES)",
        "values (#{appId}, #{moduleName,jdbcType=VARCHAR}, ",
        "#{moduleType,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, ",
        "#{moduleCode,jdbcType=VARCHAR}, #{mVersion,jdbcType=INTEGER}, ",
        "#{createTs,jdbcType=DATE}, #{createUid,jdbcType=INTEGER}, ",
        "#{updateTs,jdbcType=DATE}, #{updateUid,jdbcType=INTEGER}, ",
        "#{states,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="moduleId", before=false, resultType=Integer.class)
    int insert(DocModule record);

    @InsertProvider(type=DocModuleSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="moduleId", before=false, resultType=Integer.class)
    int insertSelective(DocModule record);

    @SelectProvider(type=DocModuleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="MODULE_ID", property="moduleId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER),
        @Result(column="MODULE_NAME", property="moduleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="MODULE_TYPE", property="moduleType", jdbcType=JdbcType.INTEGER),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="MODULE_CODE", property="moduleCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="M_VERSION", property="mVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER),
        @Result(column="STATES", property="states", jdbcType=JdbcType.INTEGER)
    })
    List<DocModule> selectByExample(DocModuleExample example);

    @Select({
        "select",
        "MODULE_ID, APP_ID, MODULE_NAME, MODULE_TYPE, PID, MODULE_CODE, M_VERSION, CREATE_TS, ",
        "CREATE_UID, UPDATE_TS, UPDATE_UID, STATES",
        "from doc_module",
        "where MODULE_ID = #{moduleId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="MODULE_ID", property="moduleId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER),
        @Result(column="MODULE_NAME", property="moduleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="MODULE_TYPE", property="moduleType", jdbcType=JdbcType.INTEGER),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="MODULE_CODE", property="moduleCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="M_VERSION", property="mVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER),
        @Result(column="STATES", property="states", jdbcType=JdbcType.INTEGER)
    })
    DocModule selectByPrimaryKey(Integer moduleId);

    @UpdateProvider(type=DocModuleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocModule record, @Param("example") DocModuleExample example);

    @UpdateProvider(type=DocModuleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocModule record, @Param("example") DocModuleExample example);

    @UpdateProvider(type=DocModuleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocModule record);

    @Update({
        "update doc_module",
        "set APP_ID = #{appId,jdbcType=INTEGER},",
          "MODULE_NAME = #{moduleName,jdbcType=VARCHAR},",
          "MODULE_TYPE = #{moduleType,jdbcType=INTEGER},",
          "PID = #{pid,jdbcType=INTEGER},",
          "MODULE_CODE = #{moduleCode,jdbcType=VARCHAR},",
          "M_VERSION = #{mVersion,jdbcType=INTEGER},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER},",
          "STATES = #{states,jdbcType=INTEGER}",
        "where MODULE_ID = #{moduleId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocModule record);
}